package com.galeno.day03.transfer;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

import java.util.Random;
import java.util.Scanner;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/10/2211:36
 */
public class BuLongFilter {
    public static void main(String[] args) {
        BloomFilter<Integer> bloomFilter = BloomFilter.create(Funnels.integerFunnel(), Integer.MAX_VALUE, 0.001);
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i <100 ; i++) {

            bloomFilter.put(random.nextInt(1000));

        }
        while (true){
            int i = scanner.nextInt();
            boolean b = bloomFilter.mightContain(i);
            if (b){
                System.out.println(i+"存在");
            }else {
                System.out.println("不存在");
            }
        }


    }
}
